home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / guile-ii.src / guile-ii / guile-src / slib / macscheme.init < prev    next >
Encoding:
Text File  |  1995-01-04  |  8.1 KB  |  266 lines

  1. ;;;"macscheme.init" Configuration of *features* for MacScheme    -*-scheme-*-
  2. ;Copyright (C) 1994 Aubrey Jaffer
  3. ;
  4. ;Permission to copy this software, to redistribute it, and to use it
  5. ;for any purpose is granted, subject to the following restrictions and
  6. ;understandings.
  7. ;
  8. ;1.  Any copy made of this software must include this copyright notice
  9. ;in full.
  10. ;
  11. ;2.  I have made no warrantee or representation that the operation of
  12. ;this software will be error-free, and I am under no obligation to
  13. ;provide any services, by way of maintenance, update, or otherwise.
  14. ;
  15. ;3.  In conjunction with products arising from the use of this
  16. ;material, there shall be no use of my name in any advertising,
  17. ;promotional, or sales literature without prior written consent in
  18. ;each case.
  19.  
  20. ;;; From: jjb@isye.gatech.edu (John Bartholdi)
  21.  
  22. ;;; (software-type) should be set to the generic operating system type.
  23. ;;; UNIX, VMS, MACOS, AMIGA and MS-DOS are supported.
  24.  
  25. (define (software-type) 'MACOS)
  26.  
  27. ;;; (scheme-implementation-type) should return the name of the scheme
  28. ;;; implementation loading this file.
  29.  
  30. (define (scheme-implementation-type) 'MacScheme)
  31.  
  32. ;;; (scheme-implementation-version) should return a string describing
  33. ;;; the version the scheme implementation loading this file.
  34.  
  35. (define (scheme-implementation-version) "4.2")
  36.  
  37. ;;; (implementation-vicinity) should be defined to be the pathname of
  38. ;;; the directory where any auxillary files to your Scheme
  39. ;;; implementation reside.
  40.  
  41. (define (implementation-vicinity) "Macintosh.HD:MacScheme 4.2:")
  42.  
  43. ;;; (library-vicinity) should be defined to be the pathname of the
  44. ;;; directory where files of Scheme library functions reside.
  45.  
  46. (define (library-vicinity) "Macintosh.HD:MacScheme 4.2:slib:")
  47.  
  48. ;;; *FEATURES* should be set to a list of symbols describing features
  49. ;;; of this implementation.  Suggestions for features are:
  50.  
  51. (define *features*
  52.       '(
  53.     source                ;can load scheme source files
  54.                     ;(slib:load-source "filename")
  55. ;    compiled            ;can load compiled files
  56.                     ;(slib:load-compiled "filename")
  57.     rev4-report            ;conforms to
  58.     rev3-report            ;conforms to
  59.     ieee-p1178            ;conforms to
  60. ;    sicp                ;runs code from Structure and
  61.                     ;Interpretation of Computer
  62.                     ;Programs by Abelson and Sussman.
  63.     rev4-optional-procedures    ;LIST-TAIL, STRING->LIST,
  64.                     ;LIST->STRING, STRING-COPY,
  65.                     ;STRING-FILL!, LIST->VECTOR,
  66.                     ;VECTOR->LIST, and VECTOR-FILL!
  67.     rev3-procedures            ;LAST-PAIR, T, and NIL
  68. ;    rev2-procedures            ;SUBSTRING-MOVE-LEFT!,
  69.                     ;SUBSTRING-MOVE-RIGHT!,
  70.                     ;SUBSTRING-FILL!,
  71.                     ;STRING-NULL?, APPEND!, 1+,
  72.                     ;-1+, <?, <=?, =?, >?, >=?
  73.     multiarg/and-            ;/ and - can take more than 2 args.
  74.     multiarg-apply            ;APPLY can take more than 2 args.
  75.     rationalize
  76.     delay                ;has DELAY and FORCE
  77.     with-file            ;has WITH-INPUT-FROM-FILE and
  78.                     ;WITH-OUTPUT-FROM-FILE
  79.     string-port            ;has CALL-WITH-INPUT-STRING and
  80.                     ;CALL-WITH-OUTPUT-STRING
  81. ;    transcript            ;TRANSCRIPT-ON and TRANSCRIPT-OFF
  82. ;    char-ready?
  83. ;    macro                ;has R4RS high level macros
  84. ;    defmacro            ;has Common Lisp DEFMACRO
  85.     eval                ;SLIB:EVAL is single argument eval
  86. ;    record                ;has user defined data structures
  87. ;    values                ;proposed multiple values
  88. ;    dynamic-wind            ;proposed dynamic-wind
  89.     ieee-floating-point        ;conforms to
  90.     full-continuation        ;can return multiple times
  91. ;    object-hash            ;has OBJECT-HASH
  92.  
  93. ;    sort
  94. ;    queue                ;queues
  95.     pretty-print
  96. ;    object->string
  97. ;    format
  98. ;    trace                ;has macros: TRACE and UNTRACE
  99.     compiler            ;has (COMPILER)
  100. ;    ed                ;(ED) is editor
  101. ;    system                ;posix (system <string>)
  102. ;    getenv                ;posix (getenv <string>)
  103. ;    program-arguments        ;returns list of strings (argv)
  104. ;    Xwindows            ;X support
  105. ;    curses                ;screen management package
  106. ;    termcap                ;terminal description package
  107. ;    terminfo            ;sysV terminal description
  108.     ))
  109.  
  110. ;;; (OUTPUT-PORT-WIDTH <port>)
  111. (define (output-port-width . arg) 79)
  112.  
  113. ;;; (OUTPUT-PORT-HEIGHT <port>)
  114. (define (output-port-height . arg) 24)
  115.  
  116. ;;; (CURRENT-ERROR-PORT)
  117. (define current-error-port
  118.   (let ((port (current-output-port)))
  119.     (lambda () port)))
  120.  
  121. ;;; (TMPNAM) makes a temporary file name.
  122. (define tmpnam (let ((cntr 100))
  123.          (lambda () (set! cntr (+ 1 cntr))
  124.              (string-append "slib_" (number->string cntr)))))
  125.  
  126. ;;; (FILE-EXISTS? <string>)
  127. (define (file-exists? f) #f)
  128.  
  129. ;;; (DELETE-FILE <string>)
  130. (define (delete-file f) #f)
  131.  
  132. ;;; FORCE-OUTPUT flushes any pending output on optional arg output port
  133. ;;; use this definition if your system doesn't have such a procedure.
  134. (define (force-output . arg) #t)
  135.  
  136. ;;; CALL-WITH-INPUT-STRING and CALL-WITH-OUTPUT-STRING are the string
  137. ;;; port versions of CALL-WITH-*PUT-FILE.
  138. (define (call-with-output-string f)
  139.   (let ((outsp (open-output-string)))
  140.     (f outsp)
  141.     (let ((s (get-output-string outsp)))
  142.       (close-output-port outsp)
  143.       s)))
  144.  
  145. (define (call-with-input-string s f)
  146.   (let* ((insp (open-input-string s))
  147.      (res (f insp)))
  148.     (close-input-port insp)
  149.     res))
  150.  
  151. ;;; CHAR-CODE-LIMIT is one greater than the largest integer which can
  152. ;;; be returned by CHAR->INTEGER.
  153. (define char-code-limit 256)
  154.  
  155. ;;; MOST-POSITIVE-FIXNUM is used in modular.scm
  156. (define most-positive-fixnum 536870911)
  157.  
  158. ;;; Return argument
  159. (define (identity x) x)
  160.  
  161. ;;; If your implementation provides eval SLIB:EVAL is single argument
  162. ;;; eval using the top-level (user) environment.
  163. (define slib:eval eval)
  164.  
  165. ;;; If your implementation provides R4RS macros:
  166. ;(define macro:eval slib:eval)
  167. ;(define macro:load load)
  168.  
  169. (define *defmacros*
  170.   (list (cons 'defmacro
  171.           (lambda (name parms . body)
  172.         `(set! *defmacros* (cons (cons ',name (lambda ,parms ,@body))
  173.                       *defmacros*))))))
  174. (define (defmacro? m) (and (assq m *defmacros*) #t))
  175.  
  176. (define (macroexpand-1 e)
  177.   (if (pair? e) (let ((a (car e)))
  178.           (cond ((symbol? a) (set! a (assq a *defmacros*))
  179.                      (if a (apply (cdr a) (cdr e)) e))
  180.             (else e)))
  181.       e))
  182.  
  183. (define (macroexpand e)
  184.   (if (pair? e) (let ((a (car e)))
  185.           (cond ((symbol? a)
  186.              (set! a (assq a *defmacros*))
  187.              (if a (macroexpand (apply (cdr a) (cdr e))) e))
  188.             (else e)))
  189.       e))
  190.  
  191. (define gentemp
  192.   (let ((*gensym-counter* -1))
  193.     (lambda ()
  194.       (set! *gensym-counter* (+ *gensym-counter* 1))
  195.       (string->symbol
  196.        (string-append "slib:G" (number->string *gensym-counter*))))))
  197.  
  198. (define base:eval slib:eval)
  199. (define (defmacro:eval x) (base:eval (defmacro:expand* x)))
  200. (define (defmacro:expand* x)
  201.   (require 'defmacroexpand) (apply defmacro:expand* x '()))
  202.  
  203. (define (defmacro:load <pathname>)
  204.   (slib:eval-load <pathname> defmacro:eval))
  205.  
  206. (define (slib:eval-load <pathname> evl)
  207.   (if (not (file-exists? <pathname>))
  208.       (set! <pathname> (string-append <pathname> (scheme-file-suffix))))
  209.   (call-with-input-file <pathname>
  210.     (lambda (port)
  211.       (let ((old-load-pathname *load-pathname*))
  212.     (set! *load-pathname* <pathname>)
  213.     (do ((o (read port) (read port)))
  214.         ((eof-object? o))
  215.       (evl o))
  216.     (set! *load-pathname* old-load-pathname)))))
  217.  
  218. ;;; define an error procedure for the library
  219. (define slib:error
  220.   (lambda args
  221.     (cerror "Error: " args)))
  222.  
  223. ;;; define these as appropriate for your system.
  224. (define slib:tab #\tab)
  225. (define slib:form-feed #\page)
  226.  
  227. ;;; Define these if your implementation's syntax can support it and if
  228. ;;; they are not already defined.
  229.  
  230. ;(define (1+ n) (+ n 1))
  231. ;(define (-1+ n) (+ n -1))
  232. ;(define 1- -1+)
  233.  
  234. (define in-vicinity string-append)
  235.  
  236. ;;; Define SLIB:EXIT to be the implementation procedure to exit or
  237. ;;; return if exitting not supported.
  238. ; MacScheme does not return a value when it exits,
  239. ; so simply invoke system procedure exit with 0 args.
  240. (define slib:exit (lambda args (exit)))
  241.  
  242. ;;; Here for backward compatability
  243. (define scheme-file-suffix
  244.   (let ((suffix (case (software-type)
  245.           ((NOSVE) "_scm")
  246.           (else ".scm"))))
  247.     (lambda () suffix)))
  248.  
  249. ;;; (SLIB:LOAD-SOURCE "foo") should load "foo.scm" or with whatever
  250. ;;; suffix all the module files in SLIB have.  See feature 'SOURCE.
  251.  
  252. ;(define slib:load-source load)
  253. (define (slib:load-source f) (load (string-append f (scheme-file-suffix))))
  254.  
  255. ;;; (SLIB:LOAD-COMPILED "foo") should load the file that was produced
  256. ;;; by compiling "foo.scm" if this implementation can compile files.
  257. ;;; See feature 'COMPILED.
  258.  
  259. (define slib:load-compiled load)
  260.  
  261. ;;; At this point SLIB:LOAD must be able to load SLIB files.
  262.  
  263. (define slib:load slib:load-source)
  264.  
  265. (slib:load (in-vicinity (library-vicinity) "require"))
  266.